//对文章模块请求封装
import instance from 'utils/request'

export function getAllArticles(params) {
  return instance({
    url: '/v1_0/mp/articles',
    params,
  })
}

/**
 * 删除文章
 * @param {*} id
 * @returns
 */
export function removeArticle(id) {
  return instance({
    url: '/v1_0/mp/articles/' + id,
    method: 'DELETE',
  })
}

/**
 * 发表文章
 * @param {*} data
 * @returns
 */
export function publishArticle(data) {
  return instance({
    url: '/v1_0/mp/articles?draft=' + data.draft,
    method: 'POST',
    data,
  })
}

/**
 * 编辑文章
 * @param {*} data
 * @returns
 */
export function editArticle(data) {
  return instance({
    url: `/v1_0/mp/articles/${data.id}?draft=${data.draft}`,
    method: 'PUT',
    data,
  })
}

/**
 * 获取文章详情
 * @param {*} target
 * @returns
 */
export function loadArticle(id) {
  return instance({
    url: '/v1_0/mp/articles/' + id,
  })
}
